<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>拖车申请流程附加信息页面</title>
<jsp:include page="../../import.jsp" flush="true" />
<jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="trailCar_view">
				<div class="fieldset1 tabel_col clearFix">
					<div class="fieldBox col_50">
						<div class="label">申请人</div>
		                <div class="field">
		                    <span id="applyNm" name="applyNm">&nbsp;</span>
		                </div>
					</div>
		            <div class="fieldBox col_50">
						<div class="label">申请时间</div>
						<div class="field">
							<span id="applyDt" name="applyDt">&nbsp;</span>
						</div>
					</div>
					<!-- 基本信息 -->
					<div class="caption">
						<span class="title">基本信息</span>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">承租人</div>
						<div class="field">
							<span id="cstNm" name="cstNm">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">合同编号</div>
						<div class="field">
							<span id="contNo" name="contNo">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
		                <div class="label">支付表号</div>
		                <div class="field">
		                    <span id="paySchNo_1" name="paySchNo_1">&nbsp;</span>
		                </div>
		            </div>
		            <div class="fieldBox col_33">
						<div class="label">经销商</div>
						<div class="field">
							<span id="splNm" name="splNm">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">事业部</div>
						<div class="field">
							<span id="orgName" name="orgName">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">业务负责人</div>
						<div class="field" style="width: 100%;">
							<span id="cstMgrNm" name="cstMgrNm">&nbsp;</span>
						</div>
					</div>
					<!-- 设备信息 -->
					<div class="caption">
						<span class="title">设备信息</span>
					</div>
					<div class="fieldBox col_100">
						<div class="sqPanel">
							<div id="detailGrid">
								<!-- 设备信息列表显示块 -->
								<div id="ligergrid_equ" class="sq-grid"></div>
								<div style="text-align: center;line-height: 2.3em;" class="edit_gps_st">
									<span id="updateGpsStBtn" class="sq-button sq-button-round" onclick="updateGpsStOrBackSt()">修改</span>
								</div>
							</div>
						</div>
					</div>
					<!-- 逾期信息 -->
					<div class="caption">
						<span class="title">逾期信息</span>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">租赁周期</div>
						<div class="field">
							<span id="lsPd" name="lsPd">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">已还租金(元)</div>
						<div class="field">
							<span id="actualAmt" name="actualAmt">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
		                <div class="label">逾期租金(元)</div>
		                <div class="field">
		                    <span id="overdueAmt" name="overdueAmt">&nbsp;</span>
		                </div>
		            </div>
		            <div class="fieldBox col_33">
						<div class="label">逾期天数</div>
						<div class="field">
							<span id="overdueDay" name="overdueDay">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33">
						<div class="label">罚息金额(元)</div>
						<div class="field">
							<span id="penaltyAmt" name="penaltyAmt">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">应还款金额(元)</div>
						<div class="field">
							<span id="payAmt" name="payAmt">&nbsp;</span>
						</div>
					</div>
					<!-- 拖车信息 -->
					<div class="caption">
						<span class="title">拖车信息</span>
					</div>
		            <div class="fieldBox col_100 edit_fqr">
						<div class="label">拖车原因</div>
						<div class="field">
							<textarea name="backReason" id="backReason" rows="3" class="l-textarea" style="width:98%" value="" ></textarea>
						</div>
					</div>
		            <div class="fieldBox col_100 show_fqr">
						<div class="label">拖车原因</div>
						<div class="field">
							<span id="backReason_1" name="backReason_1">&nbsp;</span>
						</div>
					</div>
					<!-- 上传附件 -->
					<div class="fieldBox col_100 edit_fjsc">
						<div class="label">附件上传</div>
						<div class="field">
							<jsp:include page="../assCommFilesUpload.jsp" flush="true" >
								<jsp:param name="filePath" value="ass"/>
							</jsp:include>
							<div id="fileUpload1" class="upfileBoxs"></div>
							<span class="sq-button sq-button-hasicon" id="btnUpload1" onclick="ajaxFileUploadImg('uploads1',1)">
								<i class="sqBtnIco_9"></i>上传
							</span>
						</div>
					</div>
					<!-- 附件显示 -->
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
							<jsp:include page="../assCommFilesList.jsp" flush="true" ></jsp:include>
							<div id="ligergrid_file1" class="sq-grid"></div>
						</div>
					</div>
					<!-- 可编辑信息 -->
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">拖车单位名称</div>
						<div class="field">
							<input name="companyNm" id="companyNm" value="" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">拖车单位名称</div>
						<div class="field">
							<span id="companyNm_1" name="companyNm_1">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33 edit_fqr">
						<div class="label">预计拖回时间</div>
						<div class="field">
							<input name="backDt" id="backDt" type="text" class="ui-datepicker" value="" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">预计拖回时间</div>
						<div class="field">
							<span id="backDt_1" name="backDt_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_tcc_zg">
						<div class="label"></div>
						<div class="field"></div>
					</div>
					<div class="fieldBox col_66_auto edit_tcc_zg">
						<div class="label">拖回保管城市</div>
						<div class="field">
							<jsp:include page="../../system/sysRegion/region.jsp" flush="true" >
								<jsp:param name="regionShowLvl" value="2"/>
							</jsp:include>
						</div>
					</div>
					<div class="fieldBox col_33 show_tcc_zg">
						<div class="label">拖回保管城市</div>
						<div class="field">
							<span id="provinceCity_1" name="provinceCity_1">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_33 edit_tcc_zg">
						<div class="label">停车场名称</div>
						<div class="field">
							<input name="parkNm" id="parkNm" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:false}">
						</div>
					</div>
		            <div class="fieldBox col_33 show_tcc_zg">
						<div class="label">停车场名称</div>
						<div class="field">
							<span id="parkNm_1" name="parkNm_1">&nbsp;</span>
						</div>
					</div>
		            <div class="fieldBox col_66 edit_tcc_zg">
						<div class="label">停车场地址</div>
						<div class="field">
							<input name="parkAddress" id="parkAddress" value="" type="text" readonly class="ui-textbox" validate="{required:false}">
						</div>
					</div>
		            <div class="fieldBox col_33 show_tcc_zg">
						<div class="label">停车场地址</div>
						<div class="field">
							<span id="parkAddress_1" name="parkAddress_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_tcc_zg">
						<div class="label">优车资产管理员</div>
						<div class="field">
							<input name="assMgs" id="assMgs" data-value=" " placeholder="--请选择--" ltype="combobox" validate="{required:false}">
						</div>
					</div>
					<div class="fieldBox col_33 show_tcc_zg">
						<div class="label">优车资产管理员</div>
						<div class="field">
							<span id="assMgs_1" name="assMgs_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">拖车费用(元/辆)</div>
						<div class="field">
							<input name="backPrice" id="backPrice" value="" type="text" class="ui-textbox" validate="{number:true}" onchange="setBackAmt()">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">拖车费用(元/辆)</div>
						<div class="field">
							<span id="backPrice_1" name="backPrice_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">拖车数量</div>
						<div class="field">
							<input name="backQty" id="backQty" value="1" type="text" class="ui-textbox" validate="{number:true}" onchange="setBackAmt()">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">拖车数量</div>
						<div class="field">
							<span id="backQty_1" name="backQty_1" >&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">拖车费合计(元)</div>
						<div class="field">
							<input name="backAmt" id="backAmt" value="" type="text" class="ui-textbox" readonly validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">拖车费合计(元)</div>
						<div class="field">
							<span id="backAmt_1" name="backAmt_1">&nbsp;</span>
						</div>
					</div>
					<!-- 修改停车场和资管员 -->
					<div class="fieldBox col_100 edit_tcc_zg">
						<div class="sqPanel">
							<div id="detailGrid">
								<div style="text-align: center;line-height: 2.3em;">
									<span id="updateParkBtn" class="sq-button sq-button-round" onclick="saveTrailCar()">修改停车场信息</span>
								</div>
							</div>
						</div>
					</div>
					<!-- 收款信息 -->
					<div class="caption">
						<span class="title">收款信息</span>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">收款方名称</div>
						<div class="field">
							<input name="payeeAccNm" id="payeeAccNm" value="" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">收款方名称</div>
						<div class="field">
							<span id="payeeAccNm_1" name="payeeAccNm_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">开户银行</div>
						<div class="field">
							<input name="payeeBankNm" id="payeeBankNm" value="" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">开户银行</div>
						<div class="field">
							<span id="payeeBankNm_1" name="payeeBankNm_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">开户行行号</div>
						<div class="field">
							<input name="payeeBankNo" id="payeeBankNo" value="" type="text" class="ui-textbox" validate="{number:true}">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">开户行行号</div>
						<div class="field">
							<span id="payeeBankNo_1" name="payeeBankNo_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_fqr">
						<div class="label">银行账号</div>
						<div class="field">
							<input name="payeeAccNo" id="payeeAccNo" value="" type="text" class="ui-textbox" validate="{number:true}">
						</div>
					</div>
					<div class="fieldBox col_33 show_fqr">
						<div class="label">银行账号</div>
						<div class="field">
							<span id="payeeAccNo_1" name="payeeAccNo_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 Hide">
						<div class="label">实际拖回时间</div>
						<div class="field">
							<input name="actBackDt" id="actBackDt" value="" type="text" class="ui-datepicker" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 thsj">
						<div class="label">实际拖回时间</div>
						<div class="field">
							<span id="actBackDt_1" name="actBackDt_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label"></div>
						<div class="field"></div>
					</div>
					<!-- 付款信息 -->
					<div class="caption fkxx">
						<span class="title">付款信息</span>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">付款方名称</div>
						<div class="field">
							<input name="payerAccNm" id="payerAccNm" value="狮桥融资租赁（中国）有限公司" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">开户银行</div>
						<div class="field">
							<input name="payerBankNm" id="payerBankNm" data-value=" " placeholder="--请选择--" ltype="combobox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">银行账号</div>
						<div class="field">
							<input name="payerAccNo" id="payerAccNo" data-value=" " placeholder="--请选择--" ltype="combobox" validate="">
						</div>
					</div>
					<!-- 未来本金等值,实际明细 -->
					<div class="fieldBox col_33 edit_payer">
						<div class="label">未来本金(元)</div>
						<div class="field">
							<input name="futureAmt" id="futureAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">逾期租金(元)</div>
						<div class="field">
							<input name="overRentAmt" id="overRentAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 Hide">
						<div class="label">逾期罚息(元)</div>
						<div class="field">
							<input name="overInterestAmt" id="overInterestAmt" value="" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">履约保证金(元)</div>
						<div class="field">
							<input name="performanceAmt" id="performanceAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<!-- 保险保证金等值,实际明细 -->
					<div class="fieldBox col_33 edit_payer">
						<div class="label">保险保证金(元)</div>
						<div class="field">
							<input name="insureAmt" id="insureAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">其他费用(元)</div>
						<div class="field">
							<input name="otherAmt" id="otherAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">风险保证金(元)</div>
						<div class="field">
							<input name="riskAmt" id="riskAmt" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 edit_cyc">
						<div class="label">留购价(元)</div>
						<div class="field">
							<input name="rsrvPc" id="rsrvPc" value="" type="text" class="ui-textbox" onchange="calculateBaseAmt()" validate="">
						</div>
					</div>
					<!-- 实际付款时间等值,实际明细 -->
					<div class="fieldBox col_33 edit_cwfk">
						<div class="label">实际付款时间</div>
						<div class="field">
							<input name="actPayDt" id="actPayDt" value="" type="text" class="ui-datepicker" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_cwfk">
						<div class="label">实际付款时间</div>
						<div class="field">
							<span id="actPayDt_1" name="actPayDt_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_cwfk">
						<div class="label">实际付款金额(元)</div>
						<div class="field">
							<input name="actPayAmt" id="actPayAmt" value="" type="text" class="ui-textbox" validate="">
						</div>
					</div>
					<div class="fieldBox col_33 show_cwfk">
						<div class="label">实际付款金额(元)</div>
						<div class="field">
							<span id="actPayAmt_1" name="actPayAmt_1">&nbsp;</span>
						</div>
					</div>
					<div class="fieldBox col_33 edit_cwfk">
						<div class="label"></div>
						<div class="field"></div>
					</div>
					<div class="fieldBox col_33 show_cyc">
						<div class="label"></div>
						<div class="field"></div>
					</div>
					<div class="fieldBox col_33 edit_payer">
						<div class="label">保底价款(元)</div>
						<div class="field">
							<input name="baseAmt" id="baseAmt" value="" type="text" class="ui-textbox" validate="{number:true}">
						</div>
					</div>
					<!-- 记录拖车状态 -->
					<div class="caption backCd">
						<span class="title">记录拖车状态</span>
					</div>
					<div class="fieldBox col_100_auto backCd">
						<div class="label">拖车状态</div>
						<div class="field">
							<select name="backedFlagCd" id="backedFlagCd">
								<option value="0">请选择</option>
								<c:forEach items="${backFlagList }" var="back">
		                        	<option value="${back.key }">${back.value }</option>
								</c:forEach>
							</select>
							<font color="red" class="edit_backCd">&nbsp;&nbsp;温馨提示：当选择“已拖回”时，附件为必传项，请在上传附件后再次点击保存按钮！</font>&nbsp;&nbsp;
							<span id="updateBackStBtn" class="sq-button sq-button-round edit_backCd" onclick="updateGpsStOrBackSt()">记录拖车状态</span>
						</div>
					</div>
					
					<!-- 付款信息 -->
					<div class="caption payInfo_display Hide">
							<span class="title">付款方</span>
					</div>
					<div class="fieldBox col_100_auto payInfo_display Hide">
							<div class="sqPanel">
								<div id="detailGrid">
									<div style="text-align: right;line-height: 2.3em;" class="payInfo_add Hide">
											<span id="editPayInfo" class="sq-button sq-button-round" onclick="editPayInfo('')">添加</span>
									</div>
									<!-- 实际到账信息列表显示块 -->
									<div id="ligergrid_payInfo" class="sq-grid payInfo_display"></div>
								</div>
							</div>
				   </div>
					<!-- 付款信息 end -->
					<!-- 来款凭证上传附件 -->
					<div class="fieldBox col_100 payInfo_edit Hide">
						<div class="label">来款凭证上传</div>
						<div class="field">
							<div id="fileUpload2" class="upfileBoxs"></div>
							<span class="sq-button sq-button-hasicon" id="btnUpload2" onclick="ajaxFileUploadImg('uploads2',2)">
								<i class="sqBtnIco_9"></i>上传
							</span>
						</div>
					</div>
					<!-- 来款凭证附件显示 -->
					<div class="fieldBox col_100 payInfo_display Hide">
						<div style="width: 98%; margin-left: 1%;">
							<div id="ligergrid_file2" class="sq-grid payInfo_display Hide"></div>
						</div>
					</div>
					<div class="btnsBox payInfo_edit Hide">
					  <span id="savePayInfoFileBtn" class="sq-button sq-button-round" onclick="javascript:saveFile('lkpz_tc')">保存</span>
					</div>
					
					<!-- 拖车交接单 -->
	                <div class="fieldBox col_33 tcjjd">
	                	<div class="label">拖车交接单</div>
	                    <div class="field">
	                         <a class="entry Hide" href="javascript:void(0);" onclick="entryOrder('entry')">入库</a>
	                         <a class="out Hide" href="javascript:void(0);" onclick="entryOrder('out')">出库</a>
	                         <a class="detail Hide" href="javascript:void(0);" onclick="entryOrder('detail')">查看</a>
	                    </div>
	                </div>
	                <div class="fieldBox col_66 tcjjd">
	                    <div class="field">
	                         <a href="javascript:void(0);" onclick="exportAssCarHvPdf()">导出</a>
	                    </div>
	                </div>
	                <!-- 车辆出入库资料  -->
					<div class="caption crkzl">
						<span class="title">车辆出入库资料</span>
					</div>
					<!-- 附件显示 -->
					<div class="fieldBox col_100 crkzl">
						<div style="width: 98%; margin-left: 1%;">
							<div id="ligergrid_file3" class="sq-grid"></div>
						</div>
					</div>
					<!-- 隐藏支付表主键、支付表号 -->
	                <div class="fieldBox col_100" style="display:none;">
	                    <div class="field">
	                         <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="">
	                         <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
	                         <input name="prjId" id="prjId" type="text" class="ui-textbox" value="">
	                         <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="${tcMasterId }">
	                         <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="">
	                         <input name="tcInfoId" id="tcInfoId" type="text" class="ui-textbox" value="">
	                         <input name="flag" id="flag" type="text" class="ui-textbox" value="${flag }">
	                         <!-- 上传文件使用：系统时间和当前登录人姓名 -->
	                         <input name="sysDate" id="sysDate" type="text" class="ui-textbox" value="${sysDate }">
	                         <input name="loginUsrNm" id="loginUsrNm" type="text" class="ui-textbox" value="${loginUsrNm }">
	                         <input name="proIntId" id="proIntId" type="text" class="ui-textbox" value="${proIntId }">
	                         <input name="parkId" id="parkId" type="text" class="ui-textbox" value="">
	                    </div>
	                </div>
				</div>
				<div class="btnsBox saveBtn">
					<span id="saveTrailCarBtn" class="sq-button sq-button-round" onclick="saveTrailCar()">保存</span>
				</div>
			</form>
		</div>
	</div>

    <script>
		//修改时数据初始值
    	var _parkNmUpdataValue = "";//停车场
		var _assMgsUpdataValue = "";//资产管理员
		var _bankNmUpdataValue = "";//付款开户银行
		var _accNoUpdataValue = "";//银行账号
    	var _isUpload = 0;//是否上传了附件
	    $(function() {
	    	initForm();//初始化表单
	        initData();//初始化数据
	        showOrEdit();//显示还是编辑
	    	loadFilesLiger("tcsq", 1, $("#tcMasterId").val());//加载拖车申请文件列表信息
	    	loadFilesLiger("lkpz_tc", 2, $("#tcMasterId").val());//加载来款凭证文件列表信息
	        tipsInfo();//文本框小提示
	    });
		
		//初始化表单
		function initForm(){
	    	$("#trailCar_view").ligerForm({
				validate: true
			});
			$("#trailCar_view").check_ligerFormEditor();//重新刷新页面动态字段
		};
	    
	    //初始化数据
	    function initData(){
	    	var tcMasterId = $("#tcMasterId").val();
	    	if(!tcMasterId){
	    		$.ligerDialog.SQalert({content: "拖车申请主表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}
	    	//var wait_dialog= $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_LOADING,SQ_type: "waitting"};
	    	//加载设备信息
	    	initGrid_equ(tcMasterId);
	    	//加载拖车主表信息
	    	var _url = '<%=path%>/ass/assTrailCarM/getTrailCarMaster.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{tcMasterId:tcMasterId},
	    		url: _url,
	    		success:function(msg){
	    			 //wait_dialog.close();
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
	
	    //设置页面数据
	    function setData(data){
	    	//加载表单
	    	var form = liger.get("trailCar_view");
			form.setData({
				companyNm: data.companyNm,
				backDt: renderDate1(data.backDt),
				//backPrice: data.backPrice / 100,
				//backQty: data.backQty,
				//backAmt: data.backAmt / 100,
				parkId: data.parkId,
				payeeAccNm: data.payeeAccNm,
				payeeBankNm: data.payeeBankNm,
				payeeBankNo: data.payeeBankNo,
				payeeAccNo: data.payeeAccNo
	    	});
			//初始化区域信息
			setRgnProvCdUpdataValue(data.provinceCd);
			setRgnCityCdUpdataValue(data.cityCd);
			setParkNmUpdataValue(data.parkId);
			setAssMgsUpdataValue(data.manageId);
			initRegionProvSelectData();
			//加载日期插件
			$("#backDt").trigger("change");
			//显示申请信息
			$("#applyNm").html(data.applyNm);
 	    	$("#applyDt").html(renderDate1(data.applyDt));
			$("#backReason").val(data.backReason);
			//设置用来显示的元素值
			setTimeout(function() {
				setShowElement(data);
			}, 1000);
	    }
	    
	    //设置用来显示的元素值
	    function setShowElement(data){
			$("#companyNm_1").html(data.companyNm);
			$("#backDt_1").html(renderDate1(data.backDt));
			//$("#backPrice_1").html(data.backPrice / 100);
			//$("#backQty_1").html(data.backQty);
			//$("#backAmt_1").html(data.backAmt / 100);
			$("#payeeAccNm_1").html(data.payeeAccNm);
			$("#payeeBankNm_1").html(data.payeeBankNm);
			$("#payeeBankNo_1").html(data.payeeBankNo);
			$("#payeeAccNo_1").html(data.payeeAccNo);
			$("#backReason_1").html(data.backReason);
			//设置保管城市
			var province = getRgnProvText(data.provinceCd);
			var city = getRgnCityText(data.cityCd);
			$("#provinceCity_1").html(province + "-" + city);
			$("#parkNm_1").html(getParkText(data.parkId));
			$("#assMgs_1").html(getAssMgText(data.manageId));
			//设置付款银行信息
			setBankNmUpdataValue(getBankNmVal(data.payerBankNm));
			initBankNmSelectData();//初始化银行信息
			//设置银行账号信息
			setTimeout(function() {
				setAccNoUpdataValue(getAccNoVal(data.payerAccNo));
				initAccNoSelectData(data.payerBankNm);//初始化账号信息
			}, 500);
	    }
	    
		//初始化列表
		function initGrid_equ(id){
			var flag = $("#flag").val();
			$("#ligergrid_equ").ligerGrid({
				url:'<%=path%>/ass/assTrailCarM/getTrailCarDetail.do',
				method:'get',
				parms:{tcMasterId:id},
				columns:[
					{ display: '租赁物名称', name: 'prdNm', minWidth: 160, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = rowdata.prdNm;
							initPkData(rowdata);//设置主键值及主要信息
							return h;
						}},
					{ display: '型号', name: 'prdMdl', minWidth: 150 , enabledSort:true},
					{ display: '是否新车', name: 'isNew', width: 100 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '否';
							if(rowdata.isNew==1){
								h = '是';
							}
							return h;
						}},
					{ display: '<font color="red">GPS是否在线</font>', name: 'isOnline', width: 120, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
							var online = '';
				 	    	h+='<select id="isOnline" name="isOnline">';
				 	    	h+='<option value="0" ';
				 	    	if(rowdata.isOnline==0){
				 	    		h+='selected';
				 	    		online = '否';
				 	    	}
				 	    	h+='>否</option>';
				 	    	h+='<option value="1" ';
				 	    	if(rowdata.isOnline==1){
				 	    		h+='selected';
				 	    		online = '是';
				 	    	}
				 	    	h+='>是</option></select>';
				 	    	//判断是否为显示
				 	    	if(flag!="2"){
				 	    		h = online;
				 	    	}
							return h;
						}},
					{ display: '使用期限(月)', name: 'usedPd', width: 100 , enabledSort:true},
					{ display: '单价', name: 'guidePc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.guidePc / 100;
							return h;
						}},
					{ display: '数量', name: 'prdQty', width: 100, enabledSort:true},
					{ display: '留购价', name: 'rsrvPc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.rsrvPc / 100;
							return h;
						}},
					//{ display: '买卖合同编号', name: 'salContNo', width: 100 , enabledSort:true},
					{ display: '车辆配置单', name: '', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
							h+='<a href="javascript:showOp(';
			                h+="'"+rowdata.prjId+"'";
			                h+=",'"+rowdata.prjPrdId+"'";
			                h+=")\">查看</a>";
							return h;
						}}
				],
				usePager: false,//是否有分页便签
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				isScroll: false,//是否有滚动条
				checkbox:false,//列表是否有选择框
				rownumbers:true//列表是否有行号
			});
			grid = liger.get("ligergrid_equ");
			grid.options.isSingleCheck = true;//列表是否为单选
		}
		
		//车辆配置单
		function showOp(_prjId,_prjPrdId){
		    Add_navTab("corePrcBook"+_prjPrdId, "车辆配置单", '<%=path%>/audit/audStandingBook/toCorePrcBookAddPage.do?prjPrdId='+_prjPrdId+'&proIntId='+$("#proIntId").val()+'&projectId='+_prjId+'&isDetail='+1);
		}
		
		//设置关键字的值-各表主键
		function initPkData(rowdata){
			//加载表单
	    	var form = liger.get("trailCar_view");
			form.setData({
				tcDetailId: rowdata.id,//拖车明细表ID
				tcInfoId: rowdata.infoId,//拖车实际明细表ID
				paySchId: rowdata.paySchId,
				paySchNo: rowdata.paySchNo,
				prjId: rowdata.prjId,//项目ID
				backPrice: rowdata.backPrice / 100,
				backQty: rowdata.backQty,
				backAmt: rowdata.backAmt / 100,
				backedFlagCd: rowdata.backedFlagCd
	    	});
			//乘用车核算保底价-添加留购价
			if(rowdata.paySchNo.indexOf("CA")>0 && "${flag}" == "22"){
				$("#rsrvPc").val(rowdata.rsrvPc / 100);//留购价
				$("#trailCar_view").find(".edit_cyc").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//为了美观-加了空格
				$("#trailCar_view").find(".show_cyc").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}else{//不可编辑
				$("#trailCar_view").find(".edit_cyc").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			initDInfoData();//初始化实际明细信息
			//initMoneyData();//初始化金额数据
			//设置支付表可查看
			var paySchNo='<a href="javascript:payDetail(';
			paySchNo+="'"+rowdata.prjPrdDtlId+"',"; //项目产品明细信息表ID
			paySchNo+="'"+rowdata.paySchId+"',"; //支付表ID
			paySchNo+="'"+rowdata.prjPrdId+"',"; //项目产品基础信息表ID
			paySchNo+="'"+rowdata.prjId+"'"; //项目基础信息表ID
			paySchNo+=')">'+rowdata.paySchNo+'</a>';
			//设置基本信息显示
 	    	$("#cstNm").html(rowdata.cstNm);
 	    	$("#contNo").html(rowdata.contNo);
 	    	$("#paySchNo_1").html(paySchNo);
 	    	$("#splNm").html(rowdata.splNm);
 	    	$("#orgName").html(rowdata.orgName);
 	    	$("#cstMgrNm").html(rowdata.cstMgrNm);
			//设置逾期信息
			$("#lsPd").html(rowdata.lsPd);
 	    	$("#actualAmt").html(rowdata.actualAmt / 100);
 	    	$("#overdueAmt").html(rowdata.overdueAmt / 100);
 	    	$("#overdueDay").html(rowdata.overdueDay);
 	    	$("#penaltyAmt").html(rowdata.penaltyAmt / 100);
			$("#payAmt").html(rowdata.payAmt / 100);
			$("#backPrice_1").html(rowdata.backPrice / 100);
			$("#backQty_1").html(rowdata.backQty);
			$("#backAmt_1").html(rowdata.backAmt / 100);
			//加载出入库资料文件列表信息
	    	loadFilesLiger("crkzl", 3, $("#tcDetailId").val());
			
			var flag = '${flag}';
			if(rowdata.backedFlagCd ==  AssConstant.BACKED_FLAG_CD_2 || rowdata.backedFlagCd ==  AssConstant.BACKED_FLAG_CD_3){//标记拖车状态节点并且状态标记为未拖回或无法拖回
	        	if(flag == '8' || flag == '12'){
	        		$("#trailCar_view").find(".payInfo_button").each(function (){
						$(this).removeClass('Hide');
		        	});
	        		$("#trailCar_view").find(".payInfo_add").each(function (){
						$(this).removeClass('Hide');
		        	});
	        		$("#trailCar_view").find(".payInfo_edit").each(function (){
						$(this).removeClass('Hide');
		        	});
	        		 $("#trailCar_view").find(".payInfo_display").each(function (){
							$(this).removeClass('Hide');
			        }); 
	        	}else if (flag > '12'){
	        		 $("#trailCar_view").find(".payInfo_display").each(function (){
							$(this).removeClass('Hide');
			        	});
					 $("#trailCar_view").find(".payInfo_button").each(function (){
							$(this).addClass('Hide');
			        	});
		        	$("#trailCar_view").find(".payInfo_add").each(function (){
							$(this).addClass('Hide');
			        	});
		        	$("#trailCar_view").find(".payInfo_edit").each(function (){
							$(this).addClass('Hide');
			        	});
	        	}else{
	        		$("#trailCar_view").find(".payInfo_button").each(function (){
						$(this).addClass('Hide');
		        	});
	        		$("#trailCar_view").find(".payInfo_add").each(function (){
						$(this).addClass('Hide');
		        	});
	        		$("#trailCar_view").find(".payInfo_edit").each(function (){
						$(this).addClass('Hide');
		        	});
	        		 $("#trailCar_view").find(".payInfo_display").each(function (){
						$(this).addClass('Hide');
			        }); 
	        	}	
			}else{//已拖回或未选择
				$("#trailCar_view").find(".payInfo_button").each(function (){
					$(this).addClass('Hide');
	        	});
        		$("#trailCar_view").find(".payInfo_add").each(function (){
					$(this).addClass('Hide');
	        	});
        		$("#trailCar_view").find(".payInfo_edit").each(function (){
					$(this).addClass('Hide');
	        	});
        		 $("#trailCar_view").find(".payInfo_display").each(function (){
					$(this).addClass('Hide');
		        }); 
			}
		}
		
	    //初始化拖车实际明细表数据
	    function initDInfoData(){
	    	var tcInfoId = $("#tcInfoId").val();
	    	if(!tcInfoId){
	    		//$.ligerDialog.SQalert({content: "拖车实际明细表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}else{
		    	//加载拖车实际明细信息
		    	var _url = '<%=path%>/ass/assTrailCarDInf/getById.do';
		    	$.ajax({
		    		type: 'get',
		    		dataType:'json',
		    		data:{tcInfoId:tcInfoId},
		    		url: _url,
		    		success:function(msg){
		    			 if(msg.success == 1){
		    				 setDInfData(msg.data);//设置数据
		    			 }else{
		    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
		    			 }
		    		}
		    	});
	    	}
	    }
	    
	    //设置拖车实际明细信息
	    function setDInfData(data){
	    	//加载表单
	    	var form = liger.get("trailCar_view");
			form.setData({
				futureAmt: data.futureAmt / 100,
				overRentAmt: data.overRentAmt / 100,
				overInterestAmt: data.overInterestAmt / 100,
				performanceAmt: data.performanceAmt / 100,
				insureAmt: data.insureAmt / 100,
				riskAmt: data.riskAmt / 100,
				otherAmt: data.otherAmt / 100,
				baseAmt: data.baseAmt / 100,
				actPayDt: renderDate1(data.actPayDt),
				actPayAmt: data.actPayAmt / 100
	    	});
			//加载日期插件
			$("#actPayDt").trigger("change");
			$("#actPayDt_1").html(renderDate1(data.actPayDt));
			$("#actPayAmt_1").html(data.actPayAmt / 100);
			$("#actBackDt_1").html(renderDate1(data.actBackDt));
			initMoneyData(data.futureAmt);//初始化金额数据
	    }
	    
	  	//初始化财务核算保底价金额数据
	    function initMoneyData(futureAmt){
	    	var paySchId = $("#paySchId").val();
	    	if(!paySchId){
	    		//$.ligerDialog.SQalert({content: "支付表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}else{
		    	//加载拖车实际明细信息
		    	var _url = '<%=path%>/ass/assTrailCarDInf/getMoneyByPaySchId.do';
		    	$.ajax({
		    		type: 'get',
		    		dataType:'json',
		    		data:{paySchId:paySchId},
		    		url: _url,
		    		success:function(msg){
		    			 if(msg.success == 1){
		    				 setMoneyData(msg.data,futureAmt);//设置数据
		    			 }else{
		    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
		    			 }
		    		}
		    	});
	    	}
	    }
	    
	    //设置财务核算保底价金额数据
	    function setMoneyData(data,futureAmt){
	    	//加载表单
	    	var form = liger.get("trailCar_view");
	    	//var futureAmt = $("#futureAmt").val();
	    	if(!futureAmt){//为空执行
				form.setData({
					futureAmt: data.futureAmt / 100,
					overRentAmt: data.overRentAmt / 100,
					overInterestAmt: data.overInterestAmt / 100,
					performanceAmt: data.performanceAmt / 100,
					insureAmt: data.insureAmt / 100,
					riskAmt: data.riskAmt / 100,
					otherAmt: data.otherAmt / 100,
					baseAmt: data.baseAmt / 100
		    	});
		    	calculateBaseAmt();//计算保底价
	    	}
	    }
		
		//拖车申请 计算保底价
		function calculateBaseAmt(){
			var overRentAmt = (isNaN($("#overRentAmt").val()) || $("#overRentAmt").val() == '')?0:$("#overRentAmt").val();//逾期租金
			var futureAmt = (isNaN($("#futureAmt").val()) || $("#futureAmt").val()=='')?0:$("#futureAmt").val();//未来本金
			var actPayAmt = (isNaN($("#actPayAmt").val()) || $("#actPayAmt").val()=='')?0:$("#actPayAmt").val();//实际付款金额
			var otherAmt = (isNaN($("#otherAmt").val()) || $("#otherAmt").val()=='')?0:$("#otherAmt").val();//其他费用
			
			var performanceAmt = (isNaN($("#performanceAmt").val()) || $("#performanceAmt").val()=='')?0:$("#performanceAmt").val();//履约保证金
			var insureAmt = (isNaN($("#insureAmt").val()) || $("#insureAmt").val()=='')?0:$("#insureAmt").val();//保险保证金
			var riskAmt = (isNaN($("#riskAmt").val()) || $("#riskAmt").val()=='')?0:$("#riskAmt").val();//风险保证金
			var rsrvPc = (isNaN($("#rsrvPc").val()) || $("#rsrvPc").val()=='')?0:$("#rsrvPc").val();//留购价

			var baseAmt = 0;//乘用车需要加上留购价
			baseAmt = parseFloat(overRentAmt) + parseFloat(futureAmt) + parseFloat(actPayAmt) + parseFloat(rsrvPc) + 
				parseFloat(otherAmt) - parseFloat(performanceAmt) - parseFloat(insureAmt) - parseFloat(riskAmt);
			$("#baseAmt").val(anyString(baseAmt,2));//保留2位
		}
		
		//加载拖回保管城市等信息
		$(function(){
			//选定城市后-级联出停车场名字
			$("#rgnCityCd").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				//width:150,
				onChangeValue:function(value){
					if(value){
						initParkNmSelectData(value);
					}else{//清空停车场名称
						var parkNmSelectObj = liger.get("parkNm");
						parkNmSelectObj.clear();
						parkNmSelectObj.setData({});//置空下拉框数据
					}
				}
			});
			//初始化停车场名称
			$("#parkNm").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				//width:150,
				onChangeValue:function(value){
					if(value){
						initAssMgsSelectData(value);
					}else{//清空资产管理员
						var assMgsSelectObj = liger.get("assMgs");
						assMgsSelectObj.clear();
						assMgsSelectObj.setData({});//置空下拉框数据
					}
				}
			});
			//初始化资产管理员
			$("#assMgs").ligerComboBox({
				valueField: 'key',
				textField: 'value'
			});
			
			//初始化开户银行信息
			$("#payerBankNm").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				//width:150,
				onChangeValue:function(value){
					if(value){
						initAccNoSelectData(value);
					}else{//清空银行账号
						var accNoSelectObj = liger.get("payerAccNo");
						accNoSelectObj.clear();
						accNoSelectObj.setData({});//置空下拉框数据
					}
				}
			});
			//初始化银行账号信息
			$("#payerAccNo").ligerComboBox({
				valueField: 'key',
				textField: 'value'
			});
			initBankNmSelectData();//初始化银行信息
		});
		
		//查询付款银行信息
		function initBankNmSelectData(){
			$.ajax({
				type: 'post',
				dataType:'json',
				url: '<%=path%>/ass/assTrailCarM/getBankNmKvList.do',
				success:function(msg){
					 if(msg.success == 1){
						 var bankNmSelectObj = liger.get("payerBankNm");
						 if(msg.data){
							 bankNmSelectObj.setData(msg.data);
							 //设置初始值
							 if(StringUtils.isNotEmpty(_bankNmUpdataValue)){
								 bankNmSelectObj.selectValue(_bankNmUpdataValue);
							 }
						 }else{
							 bankNmSelectObj.clear();
							 bankNmSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		}
		
		//查询付款银行账号信息
		function initAccNoSelectData(value){
			if(!$("#payerAccNo").length)return;
			var bankNmSelectObj = liger.get("payerBankNm");
			var _bankId = bankNmSelectObj.findValueByText(value);
			if(!_bankId){//银行ID为空
				return;
			}
			//查询银行账号信息
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{bankId:_bankId},
				url: '<%=path%>/ass/assTrailCarM/getAccNoKvList.do',
				success:function(msg){
					 if(msg.success == 1){
						 var accNoSelectObj = liger.get("payerAccNo");
						 if(msg.data){
							 accNoSelectObj.setData(msg.data);
							//设置初始值
							if(StringUtils.isNotEmpty(_accNoUpdataValue)){
								accNoSelectObj.selectValue(_accNoUpdataValue);
							}
						 }else{
							 accNoSelectObj.clear();
							 accNoSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		}
		
		//查询停车场名字
		function initParkNmSelectData(value){
			var parkId = $("#parkId").val();
			if(!$("#parkNm").length)return;
			var citySelectObj = liger.get("rgnCityCd");
			var _cityCd = citySelectObj.findValueByText(value);
			if(!_cityCd){//市为空
				return;
			}
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{
					parkId:parkId,//申请时选择的停车场
					provinceCd:getRgnProvCd(),
					cityCd:getRgnCityCd()
				},
				url: '<%=path%>/ass/assParking/getParkNmByRgnCd.do',
				success:function(msg){
					 if(msg.success == 1){
						 var parkNmSelectObj = liger.get("parkNm");
						 if(msg.data){
							 parkNmSelectObj.setData(msg.data);
							 //设置初始值
							 if(StringUtils.isNotEmpty(_parkNmUpdataValue)){
								 parkNmSelectObj.selectValue(_parkNmUpdataValue);
							 }
						 }else{
							 parkNmSelectObj.clear();
							 parkNmSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		}
		
		//查询停车场对应资产管理员信息
		function initAssMgsSelectData(value){
			if(!$("#assMgs").length)return;
			var parkNmSelectObj = liger.get("parkNm");
			var _parkId = parkNmSelectObj.findValueByText(value);
			if(!_parkId){//停车场ID为空
				return;
			}
			//查询资产管理员
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{parkId:_parkId},
				url: '<%=path%>/ass/assParking/getAssMgsByParkId.do',
				success:function(msg){
					 if(msg.success == 1){
						 var assMgsSelectObj = liger.get("assMgs");
						 if(msg.data){
							assMgsSelectObj.setData(msg.data);
							//设置初始值
							if(StringUtils.isNotEmpty(_assMgsUpdataValue)){
								assMgsSelectObj.selectValue(_assMgsUpdataValue);
							}
						 }else{
							 assMgsSelectObj.clear();
							 assMgsSelectObj.setData({});//置空下拉框数据
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
			//查询停车场地址
	    	$.ajax({
	    		type: 'get',
	    		dataType: 'json',
	    		data: {id:_parkId},
	    		url: '<%=path%>/ass/assParking/getById.do',
	    		success:function(msg){
	    			 if(msg.success == 1){
	    				 $("#parkAddress").val(msg.data.parkAddress);//设置数据
	    				 $("#parkAddress_1").html(msg.data.parkAddress);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	    			 }
	    		}
	    	});
		}

	  	//页面调用者可根据以下方法设置修改时的数据初始值
		function setParkNmUpdataValue(value){//停车场
			_parkNmUpdataValue = value;
		}
		function setAssMgsUpdataValue(value){//资产管理员
			_assMgsUpdataValue = value;
		}
		function setBankNmUpdataValue(value){//付款开户银行
			_bankNmUpdataValue = value;
		}
		function setAccNoUpdataValue(value){//银行账号
			_accNoUpdataValue = value;
		}
		
		//获取下拉框选中值
		function getParkId(){ //停车场
			var parkNmSelectObj = liger.get("parkNm");
			var _parkId = parkNmSelectObj.getValue();
			return _parkId;
		}
		function getAssMgId(){ //资产管理员
			var assMgsSelectObj = liger.get("assMgs");
			var _assMgId = assMgsSelectObj.getValue();
			return _assMgId;
		}
		function getBankId(){ //付款开户银行
			var bankNmSelectObj = liger.get("payerBankNm");
			var _bankId = bankNmSelectObj.getValue();
			return _bankId;
		}
		function getAccNoId(){ //银行账号
			var accNoSelectObj = liger.get("payerAccNo");
			var _accNoId = accNoSelectObj.getValue();
			return _accNoId;
		}
		
		//获取下拉框选中的文本值
		function getRgnProvText(value){ //省
			var provSelectObj = liger.get("rgnProvCd");
			var _provTx = provSelectObj.findTextByValue(value);
			return _provTx;
		}
		function getRgnCityText(value){ //市
			var citySelectObj = liger.get("rgnCityCd");
			var _cityTx = citySelectObj.findTextByValue(value);
			return _cityTx;
		}
		function getParkText(value){ //停车场
			var parkNmSelectObj = liger.get("parkNm");
			var _parkId = parkNmSelectObj.findTextByValue(value);
			return _parkId;
		}
		function getAssMgText(value){ //资产管理员
			var assMgsSelectObj = liger.get("assMgs");
			var _assMgTx = assMgsSelectObj.findTextByValue(value);
			return _assMgTx;
		}
		function getBankNmText(value){ //付款开户银行
			var bankNmSelectObj = liger.get("payerBankNm");
			var _bankNm = bankNmSelectObj.findTextByValue(value);
			return _bankNm;
		}
		function getAccNoText(value){ //银行账号
			var accNoSelectObj = liger.get("payerAccNo");
			var _accNo = accNoSelectObj.findTextByValue(value);
			return _accNo;
		}
		//根据文本内容获取值
		function getBankNmVal(txt){ //付款开户银行
			var bankNmSelectObj = liger.get("payerBankNm");
			var _bankId = bankNmSelectObj.findValueByText(txt);
			return _bankId;
		}
		function getAccNoVal(txt){ //银行账号
			var accNoSelectObj = liger.get("payerAccNo");
			var _accNoId = accNoSelectObj.findValueByText(txt);
			return _accNoId;
		}
		
		//保存文件
		function saveFile(type){
			var index = 1;
			if(type == "lkpz_tc"){
				index = 2;
			}
			var docArray = JSON.stringify(getUploadResultParams(index));
	        var url = "<%=path%>/ass/assTrailCarD/uploadAttchment.do";
	        var tcMasterId = $("#tcMasterId").val();
        	if(null == docArray){
        		return false;
        	}else{
		        if(tcMasterId){//拖车主表ID不为空执行
			        //赋值附件
			        var flag = $("#flag").val();
			        var eflag = "tcsq";
		            if((flag == '12' ||flag == '8') && type == 'lkpz_tc'){
		            	eflag = "lkpz_tc";
		            }
			        var data = {
						"docArray":docArray,
						"pkId": tcMasterId,
						"flag": eflag
					};
					//请求
			        AjaxUtils.ajaxPost(url, data, function(msg){
			        	if(msg.success == 1){
			        		if((flag == '12' ||flag == '8') && _isUpload == 1){//记录拖车状态并且选择了附件
			        			_isUpload = 2;
			        		}
							if(msg.data){
								//刷新附件页面GRID方法和清空上传按钮
								refreshUlFileRecList(index);
								clearUploadResultParams(index);
							}
							if(type == 'lkpz_tc'){
								top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							}
						 }else{
							 UIUtils.alertError(msg.info);
						 }
			        }, true);
		        }else{
		        	$.ligerDialog.SQalert({content: "业务主键为空-不能保存文件！",SQ_type: "error"});
		        }
        	}
		}
		
		//显示已上传但是未保存的文件列表
		function showFiles(data, index){
			var sysDate = $("#sysDate").val();
			var loginUsrNm = $("#loginUsrNm").val();
			var f_Grid = liger.get("ligergrid_file"+index);
			var uploadJOSN = data;
			_isUpload = 1;//选择了文件但还未保存
    		for (var i=0; i< uploadJOSN.length; i++){ 
        		//添加行-追加行
        		f_Grid.addRow({fileNm: uploadJOSN[i].fileNm, crtUsrRlNm: loginUsrNm, crtTm: sysDate, doSthFlag: "1", ligerIndex: index,id:i});
    		}
		}
		
		//修改GPS在线状态-标记拖回状态
		function updateGpsStOrBackSt(){
			if(($("#flag").val() == 12 || $("#flag").val() == 8)  && AssConstant.BACKED_FLAG_CD_1 == $("#backedFlagCd").val() && _isUpload != 1){
				$.ligerDialog.SQalert({content: "请先上传拖车申请附件",SQ_type: "warning"});
				return;
			}else{
				saveFile("tcsq");//保存文件
				updateGpsStOrBackSt2();
			} 
		}
		//修改GPS在线状态-标记拖回状态
		 function updateGpsStOrBackSt2(){
			 var ligerForm = liger.get("trailCar_view");
				var url = null;//定义url
				//获取拖车信息明细表ID-为空提示-否则修改
				var tcDetailId = $("#tcDetailId").val();
				if(!tcDetailId){
					$.ligerDialog.SQalert({content: "拖车明细ID为空,无法修改！" , SQ_type: "warning" });
					return false;
				}else{
					url = '<%=path%>/ass/assTrailCarD/modify.do';
				}
				//获取表单数据
				var data = ligerForm.getData();
				data["isOnline"] = $("#isOnline").val();
				//新增拖车信息明细信息
				var wait_dialog = null;
				$.ajax({
					type: 'post',
					dataType: 'json',
					data: data,
					url: url,
					beforeSend: function(){
						wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
					},
					success:function(msg){
						wait_dialog.close();
						//返回的拖车信息明细ID不为空执行一下操作
						if(msg.success == 1){
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						}else{
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
						}
					}
				});
		 }
		//保存拖车申请信息（拖车信息主表）
		function saveTrailCar(){
			var ligerForm = liger.get("trailCar_view");
			if (!ligerForm.valid()) {
				top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; //验证不通过，不执行以下代码
			}
			//获取标识和拖车实际明细ID值
			var flag = $("#flag").val();
			var tcInfoId = $("#tcInfoId").val();
			//获取表单数据
			var data = ligerForm.getData();
			data["provinceCd"] = getRgnProvCd();
			data["cityCd"] = getRgnCityCd();
			data["parkId"] = getParkId();
			data["manageId"] = getAssMgId();
			data["flag"] = flag;
			data["payerBankNm"] = getBankNmText(getBankId());
			data["payerAccNo"] = getAccNoText(getAccNoId());
			//修改拖车信息主表数据
			var wait_dialog = null;
			var url = '';
			if(flag == "2" || flag == "12" || flag == "8"){//拖车主表信息
				url = '<%=path%>/ass/assTrailCarM/modify.do';
			}else if(flag == "9" || flag == "17"){//财务付款-实际明细表
				if(!tcInfoId){
					url = '<%=path%>/ass/assTrailCarDInf/add.do';
		    	}else{
					url = '<%=path%>/ass/assTrailCarDInf/modify.do';
		    	}
			}else if(flag == "21" || flag == "22"){//财务估算保底价-实际明细表
				if(!tcInfoId){
					url = '<%=path%>/ass/assTrailCarDInf/add.do';
		    	}else{
					url = '<%=path%>/ass/assTrailCarDInf/modify.do';
		    	}
			}
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: url,
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
						//设置实际明细表ID值
						if(!tcInfoId && msg.data){
							$("#tcInfoId").val(msg.data);
						}
						/* if(flag != "21"){
							saveFile();//保存文件
						} */
						top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
					}else{
						top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				}
			});
		}
		
		//查看支付表详情
		function payDetail(prjPrdDtlId,id,prjPrdId,prjId){
			var editFlag = true;
			Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
		}
		
		//自动计算拖车费用合计
		function setBackAmt(){
			var backPrice = $("#backPrice").val();
			var backQty = $("#backQty").val();
			var totalMoney = 0;
			if(backPrice!='' && backQty!=''){
				totalMoney = parseInt(backPrice) * parseInt(backQty);
			}
			$("#backAmt").val(totalMoney);
		}
		
		//设置显示/编辑属性
		function showOrEdit(){
	    	var flag = $("#flag").val();
			var formSet1=liger.get("trailCar_view");
			//修改GPS是否在线状态-拖车详情和收款方信息
			if(flag == "2"){//可编辑-发起人
				$("#trailCar_view").find(".edit_gps_st").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//拖车详情和收款方信息编辑状态
				$("#trailCar_view").find(".edit_fqr").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".show_fqr").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//实际拖回时间-不显示
				$("#trailCar_view").find(".thsj").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}else{//不可编辑
				$("#trailCar_view").find(".edit_gps_st").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//拖车详情和收款方信息编辑状态
				$("#trailCar_view").find(".edit_fqr").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".show_fqr").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//实际拖回时间-显示
				$("#trailCar_view").find(".thsj").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}
			//拖回保管城市和资管员编辑状态
			if(flag == "12" || flag == "8"){//可编辑-记录拖车状态
				$("#trailCar_view").find(".edit_tcc_zg").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".show_tcc_zg").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//liger.get("backedFlagCd").setDisabled(false);
				$("#trailCar_view").find(".edit_backCd").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//必填校验
	        	formSet1.setFieldValidate("parkNm", {required: true});
	        	formSet1.setFieldValidate("parkAddress", {required: true});
	        	formSet1.setFieldValidate("assMgs", {required: true});
	        	
	        	
			}else{//不可编辑
				$("#trailCar_view").find(".edit_tcc_zg").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".show_tcc_zg").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				liger.get("backedFlagCd").setDisabled(true);
				$("#trailCar_view").find(".edit_backCd").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//非必填校验
	        	formSet1.setFieldValidate("parkNm", {required: false});
	        	formSet1.setFieldValidate("parkAddress", {required: false});
	        	formSet1.setFieldValidate("assMgs", {required: false});
			}
			//付款情况等编辑状态
			if(flag == "21" || flag == "22"){//可编辑-财务估算保底价
				$("#trailCar_view").find(".fkxx").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".edit_payer").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}else{//不可编辑
				$("#trailCar_view").find(".fkxx").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".edit_payer").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			//实际付款情况编辑状态
			if(flag == "9" || flag == "17"){//可编辑-财务付款
				$("#trailCar_view").find(".fkxx").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".edit_cwfk").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".show_cwfk").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//为了美观-加了空格
				$("#trailCar_view").find(".show_cyc").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}else if(flag == "1" || flag == "2" || flag == "3" || flag == "4" || flag == "5" || flag == "6" || flag == "7"){//不显示
				$("#trailCar_view").find(".fkxx").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".edit_cwfk").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".show_cwfk").each(function (){
	        		$(this).addClass('Hide');
	        	});
				//为了美观-加了空格
				$("#trailCar_view").find(".show_cyc").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}else{//显示-不可编辑
				$("#trailCar_view").find(".fkxx").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				$("#trailCar_view").find(".edit_cwfk").each(function (){
	        		$(this).addClass('Hide');
	        	});
				$("#trailCar_view").find(".show_cwfk").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//为了美观-加了空格
				$("#trailCar_view").find(".show_cyc").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}
			//附件上传 
			if(flag == "2" || flag == "12"|| flag == "8"){//可编辑-发起人、标记拖车状态
				$("#trailCar_view").find(".edit_fjsc").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}else{//不可编辑
				$("#trailCar_view").find(".edit_fjsc").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			//是否显示标记状态信息
			if(flag == "12" ||flag == "8" || flag == "14" || flag == "15" || flag == "19" || flag == "20" || flag == "21" 
				|| flag == "10" || flag == "13" || flag == "16" || flag == "17" || flag == "18" || flag == "22"){//显示
				$("#trailCar_view").find(".backCd").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}else{//不显示
				$("#trailCar_view").find(".backCd").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			//是否显示拖车交接单信息
			if(flag == "14" || flag == "19" || flag == "21" 
				|| flag == "10" || flag == "13" || flag == "16" || flag == "17" || flag == "18" || flag == "22"){//显示
				$("#trailCar_view").find(".tcjjd").each(function (){
	        		$(this).removeClass('Hide');
	        	});
				//拖车交接单编辑情况
				if(flag == "14" || flag == "10"){//入库
		        	$(".entry").removeClass('Hide');
		        	$(".out").addClass('Hide');
		        	$(".detail").addClass('Hide');
				}else{//查看
					$(".entry").addClass('Hide');
		        	$(".out").addClass('Hide');
		        	$(".detail").removeClass('Hide');
				}
			}else{//不显示
				$("#trailCar_view").find(".tcjjd").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			//是否显示拖车出入库资料信息
			if(flag == "14" || flag == "19" || flag == "10" || flag == "13"){//显示
				$("#trailCar_view").find(".crkzl").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}else{//不显示
				$("#trailCar_view").find(".crkzl").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			//是否显示保存按钮
			if(flag == "2" || flag == "9" || flag == "21" || flag == "17" || flag == "22"){//显示
				$("#trailCar_view").find(".saveBtn").each(function (){
	        		$(this).removeClass('Hide');
	        	});
			}else{//不显示
				$("#trailCar_view").find(".saveBtn").each(function (){
	        		$(this).addClass('Hide');
	        	});
			}
			
			//kfc add 170905
			$("#backedFlagCd").change(function(event) {
			            var backedFlagCd_val=$(this).val();
			            if (backedFlagCd_val == AssConstant.BACKED_FLAG_CD_2 || backedFlagCd_val == AssConstant.BACKED_FLAG_CD_3) {//未拖回、无法拖回
			        	  // if (backedFlagCd_val == '2' || backedFlagCd_val == '3') {//未拖回、无法拖回
			            	$("#trailCar_view").find(".payInfo_edit").each(function (){
				        		$(this).removeClass('Hide');
				        	});
			            	$("#trailCar_view").find(".payInfo_button").each(function (){
								$(this).removeClass('Hide');
				        	});
			            	$("#trailCar_view").find(".payInfo_add").each(function (){
								$(this).removeClass('Hide');
				        	});
			            	 $("#trailCar_view").find(".payInfo_display").each(function (){
									$(this).removeClass('Hide');
					        	});
			            }else{//已拖回或未选择
			            	$("#trailCar_view").find(".payInfo_edit").each(function (){
								$(this).addClass('Hide');
				        	});
			            	$("#trailCar_view").find(".payInfo_button").each(function (){
								$(this).addClass('Hide');
				        	});
			            	$("#trailCar_view").find(".payInfo_add").each(function (){
								$(this).addClass('Hide');
				        	});
			            	$("#trailCar_view").find(".payInfo_display").each(function (){
									$(this).addClass('Hide');
					        }); 
			            }
			});
			            
		}
		
		//入库交接单
		function entryOrder(crflag){
			var tcMasterId = $("#tcMasterId").val();//拖车主表ID
			var tcDetailId = $("#tcDetailId").val();//拖车明细ID
			var paySchId = $("#paySchId").val();//支付表ID
			var paySchNo = $("#paySchNo").val();//支付表号
			var prjId = $("#prjId").val();//项目ID
			var param = '&&tcMasterId='+tcMasterId+'&&tcDetailId='+tcDetailId+'&&crflag='+crflag;
			param += '&&paySchId='+paySchId+'&&paySchNo='+paySchNo+'&&prjId='+prjId;
			Add_navTab('entryOrder'+tcDetailId,'车辆交接单','<%=path%>/ass/assTrailCarM/toWarehousePage.do?' + param);
		}
		
		//提示消息
		function tipsInfo(){
			$('#backPrice').toFixNumber(2,
				{onToFix: function () {
							top.$.ligerDialog.SQalert({SQ_type: "warning", content: "小数点后不要超过2位数！"});
						}
				});
		}
		//导出车辆交接单PDF
	    function exportAssCarHvPdf(){
	    	var tcDetailId = $("#tcDetailId").val();//拖车明细ID
	        window.location.href='<%=path%>/ass/assTrailCarD/exportAssCarHvPdf.do?tcDetailId='+tcDetailId;
	    }
//kfc add 170905 start
	  //初始化付款信息
		var grid_payInfo = $("#ligergrid_payInfo").ligerGrid({
            url: '<%=path%>/ass/assTrailCarM/getAssDealRecAmtList.do?flag=1&dataTypeCd=3&dataId='+ $("#tcMasterId").val(),
            method: 'get',
            columns: [
                {display: '银行信息', name: 'payerBankNm', minWidth: 120, align: 'center', enabledSort: false},
                {display: '账号信息', name: 'payerAccNo', minWidth: 100, align: 'center', enabledSort: false},
                {display: '付款方名称', name: 'payerAccNm', minWidth: 120, align: 'center', enabledSort: false},
                {display: '付款金额(元)', name: 'payAmt', width: 100, align: 'center', enabledSort: false,
					render: function (rowdata, rowindex, value, column) { 
						var h = rowdata.payAmt / 100;
						return h;
					}},
				{display: '付款时间', name: 'payTm', width: 100, align:'center', enabledSort:true,
					render: function (rowdata, rowindex, value, column) { 
						var h = renderDate1(rowdata.payTm);
						return h;
					}},
			/* 	{display: '到账时间', name: 'receivedTm', width: 100, align:'center', enabledSort:true,
					render: function (rowdata, rowindex, value, column) { 
						var h = renderDate1(rowdata.receivedTm);
						return h;
					}},
                {display: '到账金额(元)', name: 'receivedAmt', width: 100, align: 'center', enabledSort: false,
					render: function (rowdata, rowindex, value, column) { 
						var h = rowdata.receivedAmt / 100;
						return h;
					}}, */
                {display: '操作', name: '', width: 150, align: 'center', enabledSort: false,
                    render:function(rowdata,rowindex,value){
                    	 var h = "";
                    	if('${flag}' == '8' || '${flag}' == '12'){//标记拖车状态
 							h+='<a class="sq-button-hasicon" style="cursor:pointer;" href="javascript:editPayInfo(';
                            h+="'"+rowdata.id+"'";
                            h+=')"><i class="sqBtnIco_4"></i>修改</a>';
 							h+='<a class="sq-button-hasicon" style="cursor:pointer;" href="javascript:deletePayInfo(';
 							h+="'"+rowdata.id+"'";
 							h+=')"><i class="sqBtnIco_7"></i>删除</a>';
                    	 }
                        return h;
                    }
                },
            ],
            //pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            heightDiff: -2,
            checkbox: true,
	        usePager: false,//是否分页
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            onSelectRow: function (rowdata,rowNum,rowEl) {
                $.extend(true, pageInApp, {seletedCompRow: rowdata});
            },
            onUnSelectRow: function (rowdata) {
                $.extend(true, pageInApp, {seletedCompRow: null});
            }
        });
        //添加付款信息
        function editPayInfo(id){
        	var param = id+"&dataId="+ $("#tcMasterId").val()+"&flag="+$("#flag").val()+"&goFlag=4";
			$.ligerDialog.open({
                width:800,
                height: 260,
                title: '编辑付款信息',
                url: '<%=path%>/ass/assTrailCarD/toRecAmtPage.do?assDealRecAmt_id='+param
			});
		}
      	//删除付款信息
   	    function deletePayInfo(id){
	   	    $.ligerDialog.confirm("是否确认删除选中的付款信息数据?", function (flag) {
	            if (flag == false)return;
	            var wait_dialog = null;
	            $.ajax({
	                type: 'post',
	                dataType: 'json',
	                data: {id: id},
	                url: '<%=path%>/ass/assTrailCarD/deleteRecAmt.do',
	                beforeSend: function () {
	                    wait_dialog = $.ligerDialog.SQalert({
	                        content: LogUtils.LOG_CMM_DATA_LOADING,
	                        SQ_type: "waitting"
	                    });
	                },
	                success: function (msg) {
	                    wait_dialog.close();
	                    if (msg.success == 1) {
	                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
	                        grid_payInfo.reload();
	                    } else {
	                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
	                    }
	                }
	            });
	        });
   	    }
//kfc add 170905 start      	
    </script>
</body>
</html>